<template>
  <div id="div_box_nav">
    <van-nav-bar
  title="注册"
  left-arrow
  @click-left="onClickLeft"
/>
  <van-form @submit="onSubmit" >
  <van-field
    v-model="username"
    name="username"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name="password"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block native-type="submit" color="#21b97a">注册</van-button>
  </div>
  <router-link to="/login" class="link" >已有账号？去登录</router-link>
</van-form>
</div>
</template>

<script>
import { RegisterFn } from '@/api/user'
export default {
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    async  onSubmit (values) {
      // console.log('submit', values)
      const res = await RegisterFn(values)
      console.log(res)// 请求成功
    },
    onClickLeft () {
      console.log(111)
    }
  }
}
</script>

<style lang="less" scoped>
.link {
  color: #069;
  font-size: 12px;
  padding-right: 20px;
  float: right;

}
.van-nav-bar {
background-color: #21b97a;
}
#div_box_nav /deep/ .van-nav-bar__title {
  color: white;
  font-size: 0.45rem;
}
</style>
